import { VuexModule, Module, Action, Mutation, getModule } from 'vuex-module-decorators';
import store from '../index';

export interface ITodoState {
  count: number;
}

@Module({ dynamic: true, store, name: 'todo', namespaced: true })
class Todo extends VuexModule implements ITodoState {
  public count = 0;

  @Mutation private SET_COUNT(count: number) {
    this.count = count;
  }

  @Action private increment() {
    this.SET_COUNT(this.count + 1);
  }
  @Action private decrement() {
    this.SET_COUNT(this.count - 1);
  }
}
export const TodoModule = getModule(Todo);
